<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Column Options</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
    <div id="app">
        <select v-model="selectedColumn">
            <option v-for="column in columns" :key="column">{{ column }}</option>
        </select>
    </div>

    <script>
        new Vue({
            el: '#app',
            data: {
                columns: [], // 存储列名的数组
                selectedColumn: '' // 选中的列名
            },
            mounted() {
                this.fetchColumnOptions(); // 在组件挂载后立即调用方法获取列名列表
            },
            methods: {
                fetchColumnOptions() {
                    axios.get('/test/ColumnOptionsServlet') // 发送请求获取列名列表
                        .then(response => {
                            this.columns = response.data.data; // 将返回的列名数组赋值给 data 中的 columns
                        })
                        .catch(error => {
                            console.error('请求失败:', error);
                        });
                }
            }
        });
    </script>
</body>
</html>
